﻿
@{
    ViewBag.Title = "查看任务处理过程";

    string json = ViewData["json"].ToString();
    Newtonsoft.Json.Linq.JObject jObject = Newtonsoft.Json.Linq.JObject.Parse(json);
    if (jObject.Value<int>("errcode") != 0)
    {
        string errmsg = jObject.Value<string>("errmsg");
        Response.Write(errmsg);
        Response.End();
        return;
    }
    string showType = Request.QueryString["showtype"] ?? "0";
    string flowid = "";
    Newtonsoft.Json.Linq.JArray jArray = jObject.Value<Newtonsoft.Json.Linq.JArray>("data");
    if (jArray.Count > 0)
    {
        flowid = jArray.First.Value<string>("FlowId");
    }
}
<div>
    <input type="button" value="列表" onclick="window.location='ShowTasks?groupid=@Request.QueryString["groupid"]&showtype=0'" />
    <input type="button" value="图形" onclick="window.location='ShowTasks?groupid=@Request.QueryString["groupid"]&showtype=1'" />
</div>
@if ("0" == showType)
{
    <div>
        <table class="listtable" border="1">
            <thead>
                <tr>
                    <th>步骤名称</th>
                    <th>发送人</th>
                    <th>接收时间</th>
                    <th>处理人</th>
                    <th>完成时间</th>
                    <th>状态</th>
                    <th>意见</th>
                    <th>备注</th>
                </tr>
            </thead>
            <tbody>
                @foreach (Newtonsoft.Json.Linq.JObject task in jArray)
                {
                    string receivetime = task.Value<string>("ReceiveTime");
                    string completedtime = task.Value<string>("CompletedTime1");
                    <tr>
                        <td>@(task.Value<string>("StepName"))</td>
                        <td>@(task.Value<string>("SenderName"))</td>
                        <td>@(receivetime.IsDateTime() ? DateTime.Parse(receivetime).ToString("yyyy-MM-dd HH:mm") : "")</td>
                        <td>@(task.Value<string>("ReceiveName"))</td>
                        <td>@(completedtime.IsDateTime() ? DateTime.Parse(completedtime).ToString("yyyy-MM-dd HH:mm") : "")</td>
                        <td>@(RoadFlow.IntegrateTest.Common.Tools.GetStatusTitle(task.Value<int>("Status")))</td>
                        <td>@(task.Value<string>("Comment"))</td>
                        <td>@(task.Value<string>("Note"))</td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}
else if ("1".Equals(showType))
{
    <div style="padding:8px 5px 0 10px;">
        <div style="float:left; height:12px; width:12px; background:#2b9425; margin-top:2px; border-radius:4px; margin-left:6px;"></div>
        <div style="float:left;font-size:12px; margin-left:3px;">已完成步骤</div>
        <div style="float:left; height:12px; width:12px; background:#d41d05; margin-top:2px; border-radius:4px; margin-left:12px;"></div>
        <div style="float:left;font-size:12px;margin-left:3px;">当前步骤</div>
    </div>

    <div id="flowdiv" style="margin:0; padding:0;"></div>
    <script src="@(RoadFlow.IntegrateTest.Common.Tools.ApiAddress)/RoadFlowResources/scripts/flowDesigner/draw-min.js"></script>
    <script src="@(RoadFlow.IntegrateTest.Common.Tools.ApiAddress)/RoadFlowResources/scripts/flowDesigner/workflow-show.js"></script>
    <script type="text/javascript">
        var isshowDesign = true;
        var flowJson = @Html.Raw(RoadFlow.IntegrateTest.Common.Tools.GetFlowJson(Guid.Parse(flowid)).ToString(Newtonsoft.Json.Formatting.None));
        var tasksJson = @Html.Raw(RoadFlow.IntegrateTest.Common.Tools.GetShowDesignerTaskJson(jArray).ToString(Newtonsoft.Json.Formatting.None));
        $(window).load(function () {
            reloadFlow(flowJson.data, tasksJson);
    });
    </script>

}

